package com.seedwill.common.oxm;

import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.converters.collections.CollectionConverter;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.mapper.Mapper;

public class HibernateCollectionConverter extends CollectionConverter {
	HibernateCollectionConverter(Mapper mapper) {
		super(mapper);
	}

	@Override
	protected Object readItem(HierarchicalStreamReader reader,
			UnmarshallingContext context, Object current) {
		// TODO Auto-generated method stub
		if (current instanceof org.hibernate.collection.PersistentSet) {
			@SuppressWarnings("unused")
			org.hibernate.collection.PersistentSet set = (org.hibernate.collection.PersistentSet) current;
			// set.get
		}

		return super.readItem(reader, context, current);

	}

	@SuppressWarnings("unchecked")
	public boolean canConvert(Class type) {
		return super.canConvert(type)
				|| type == org.hibernate.collection.PersistentList.class
				|| type == org.hibernate.collection.PersistentSet.class
				|| type == org.hibernate.collection.PersistentBag.class
				|| type == org.hibernate.collection.PersistentIdentifierBag.class
				|| type == org.hibernate.collection.PersistentSortedSet.class;
	}
}
